<script setup>
import MyForm from "@/components/MyForm.vue";
import {ref, shallowReactive, shallowRef} from "vue";
import {RULE} from "@/const";
import MyNav from "@/components/MyNav.vue";
import router from "@/router";
import {updateApi} from "@/api/SchoolApi";
// 获取学校记录
let school = JSON.parse(sessionStorage.getItem('school'));
console.log(school)

// 表单项
let items = shallowRef([
  {'label': '学校名称', 'prop': 'title'},
  {'label': '学院名称', 'prop': 'college'},
  {'label': '专业名称', 'prop': 'major'},
  {'label': '班级名称', 'prop': 'clazz'},
  {'label': '学校地址', 'prop': 'address', 'type': 'textarea'},
  {'label': '学校描述', 'prop': 'info', 'type': 'textarea'},
]);
// 表单默认值
let data = shallowReactive({
  'id': school['id'],
  'title': school['title'],
  'college': school['college'],
  'major': school['major'],
  'clazz': school['clazz'],
  'address': school['address'],
  'info': school['info'],
});
// 表单规则
let rules = {
  'info': RULE.COMMON_INFO,
  'title': RULE.COMM_TITLE,
};
</script>

<template>

  <my-nav :items="[
  {'icon': 'User', 'label': '员工管理'},
  {'icon': 'User', 'label': '学校列表', 'url': '/rms/School'},
  {'icon': 'User', 'label': '修改学校'},
]"/>

  <el-divider/>
  <my-form type="update"
           :items="items"
           :data="data"
           :rules="rules"
           :api="updateApi"
           :fn="() => router.push('/rms/School')"
           :span="2"/>

</template>

<style scoped lang="scss">

</style>